use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;

my $sel = Test::WWW::Selenium->new( host => "localhost", 
                                    port => 4444, 
                                    browser => "*firefox", 
                                    browser_url => "http://localhost.com" );

$sel->open_ok("/extensions/BugPrediction/lib/tests/Selenium/removeSeleniumTest.cgi");
WAIT: {
    for (1..60) {
        if (eval { $sel->is_text_present("Done!") }) { pass; last WAIT }
        sleep(1);
    }
    fail("timeout");
}
$sel->is_text_present_ok("Done!");
$sel->open_ok("/");
#$sel->click_ok("log_in_top");
$sel->wait_for_page_to_load_ok("30000");
$sel->is_element_present_ok("link=Log out");
$sel->click_ok("link=Administration");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("link=Products");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("//table[\@id='admin_table']//a[contains(\@href,'SeleniumTest')]/../../td[7]/a");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("delete_series");
$sel->click_ok("delete");
$sel->wait_for_page_to_load_ok("30000");
$sel->text_is("message", "The product SeleniumTest and all its versions, components, milestones and group controls have been deleted.");
